#!/usr/bin/php
<?
// $Id: update_all_child_lists.php 81 2011-01-04 01:27:08Z MartinS $
error_reporting(E_ALL^E_NOTICE);
$accountSuffix='_7'; // This must be specified before including boot.php
$htmlOutput = false; // This must be specified before including boot.php
include("boot.php");
include("inc/children.php");
$editInitiator = '[T7/r' . (revisionID() + 1) . ']';
$ON = true; // Override later if necessary

print "\nGetting a list of all taxa: ";
$all_pages = getPrefixIndex("Taxonomy/", 10, "Taxonomy/" . $argument["start"][0]);
print count($all_pages) . " pages in total";
print "\nGetting taxa that are already converted: ";
$already_done = getPrefixIndex("Child taxa", 10, "Child taxa/" );
print count($already_done) . " taxa already have children templates.\n";
foreach ($already_done as $taxon) {
  $done_taxa[] = substr($taxon, 22);
}

foreach ($all_pages as $page) {
  $title = substr($page, 18);
  if (true || !in_array($title, $done_taxa)) {
      print (writeChildren($title, " (automatic update via uacl)")
            ? "\nWritten to Template:Child taxa/$title"
            : "\nCouldn't write to Template:Child taxa/$title");
  } else print ".";
}

die ("\n\n === stop here. === \n");